package player.ui.dialog;

import java.awt.Component;
import java.util.HashMap;
import java.util.Iterator;

import javax.swing.JComponent;
import javax.swing.JScrollPane;

import player.ui.GlassLayout;

public class TableShowPanel extends JComponent{
	private static final long serialVersionUID = 3811737456466594442L;
	HashMap<Object, Component> componentTable;
	HashMap<Object, Component> tableTable;
	
	public TableShowPanel(){
		super();
		this.setLayout(new GlassLayout());
		componentTable=new HashMap<Object, Component>();
		tableTable=new HashMap<Object, Component>();
	}
	
	void show(Object ob){
		Component cp=componentTable.get(ob);
		Iterator<Object> it=componentTable.keySet().iterator();
		while(it.hasNext()){
			Component cpp=componentTable.get(it.next());
			if(!cp.equals(cpp)){
				cpp.setVisible(false);
			}
		}
		cp.setVisible(true);
		this.validate();
	}
	
	Component getTable(Object ob){
		return tableTable.get(ob);
	}
	
	void addComponent(Object ob,Component cp,MyJTable table){
		componentTable.put(ob, cp);
		tableTable.put(ob, table);
		add(cp);
	}
	
	boolean containsComponent(Object ob){
		return componentTable.containsKey(ob);
	}

}
